package elements;

import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import scaler.Scaler;

import mover.GameMover;

public class GameImage extends GameElement {
	private BufferedImage image;

	public GameImage(GameMover mover,Scaler scaler, BufferedImage image) {
		super(mover, scaler);
		this.image = image;
	}
	
	public GameImage(GameMover mover, Scaler scaler, String path) {
		super(mover, scaler);
		
		try {
			image = ImageIO.read(new File(path));
		} catch (IOException e) {
			e.printStackTrace();
		}
	 }

	@Override
	public void paint(Graphics g) {
		if(trans == NOT_VISIBLE) return;
		
		g.drawImage(image, super.getMovedX(), super.getMovedY(), scaler.calcX(image.getWidth()), scaler.calcX(image.getHeight()), null);
	}

	@Override
	public int getWidth() {
		return image.getWidth();
	}

	@Override
	public int getHeight() {
		return image.getHeight();
	}

	@Override
	public GameImage clone() throws CloneNotSupportedException {
		GameImage clone = new GameImage(this.mover.clone(), this.scaler, this.image);
		this.clone_help(clone);
		
		return clone;
	}

}
